import java.util.Scanner;
public class AverageMaxMin{
  // Finds the Average, Maximum, and Minimum of a number of grades
  public static void main(String[] args){
    int count = 0;
    double grade, sumOfGrades = 0.0;
    Scanner scanner = new Scanner(System.in);
    
    System.out.printf("Enter grade#%d ( 0 < or > 100 to terminate)%n", count+1);
    grade = scanner.nextDouble();
    double max = grade;     // Assume the first grade is the max
    double min = grade;     // Assume the first grade is the min
    while(grade >= 0 && grade <= 100){
       count++;
       sumOfGrades += grade;
    
       if(grade > max)
          max = grade;
       else if(grade < min)
         min = grade;
    
       System.out.printf("Enter grade#%d ( 0 < or > 100 to terminate)%n", count+1);
       grade = scanner.nextDouble();  
    }
    if(count == 0)
      System.out.println("Error: No valid grade entered");
    else{
       System.out.printf("Average = %.2f\n", sumOfGrades / count);
       System.out.printf("Maximum = %.2f\n", max);
       System.out.printf("Minimum = %.2f\n", min);
    }
      
  }
}
